package com.jeasy.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


/**
 * @author taomk
 * @version 1.0
 * @since 2014/9/22 14:33
 */
public final class PairUtils {

	private PairUtils() {
	}

    public static <U,V> List<U> extractFirst(Collection<Pair<U, V>> pairs) {
        List<U> result = new ArrayList<>(pairs.size());
        for (Pair<U, V> pair : pairs) {
            result.add(pair.getFirst());
        }
        return result;
    }

    public static <U,V> List<V> extractSecond(Collection<Pair<U, V>> pairs) {
        List<V> result = new ArrayList<V>(pairs.size());
        for (Pair<U, V> pair : pairs) {
            result.add(pair.getSecond());
        }
        return result;
    }
}
